/**
 * 
 */
//搜索框输入后直接下拉显示相关的商品名称
/*$(".search-input").on("input",function(){
	var search=$(this).val().trim();
	$(".spmch").remove();
	$(".spmch2").remove();
	if(search!=null&&search!=""){
		$.ajax({
			url:"Search",
			data:{search: search},
			type: "post",
			success:function(data){
				var result="<div class='result'></div>";
				$(".pagetop").append(result);
        		 $.each(data,function(i,v){
        			 //alert(v.spmch);
        			 var sp="<span class='spmch' style='background:#fff'>"+v.spmch+"</span></br>";
        			 $(".result").append(sp);
        		 })
			}
		})
	}
})*/
$(".search-input").on("input",function(){
	var search=$(this).val().trim();
	if(!search){//输入框删除输入内容后，再次显示输入之前显示的商品
		$(".pop-itema").show();
		if(initsize==0){
			$(".pop-itema").remove();
		}else{
			$(".pop-itema:gt("+(initsize-1)+")").remove();
		}
	}
})
$(".search_button").on("click",function(){
	if(!user){
		location.href="login?sjid="+sjid;
		return;//未登录，不能搜索
	}
	var search=$(".search-input").val().trim();
	if(search!=null&&search!=""){
		$.ajax({
			url:"Search",
			data:{search: search,sjid: sjid},
			type: "post",
			success:function(data){
				//if(data.length>0){
					$(".pop-itema,.weui-loadmore").hide();
					$.each(data,function(i,v){
						var list="<a href='javascript:;' class='pop-itema' spid='"+v.spid+"'>"
							+"<div class='pop_item'>"
							+"<div class='pop_img'>"
							//+"<img class='lazy' src='images/product/"+v.spid+"/0.jpg' />"
							//+"<img class='lazy' src='http://www.hnhcyy.com/resource/img/"+v.spid+"/0.jpg' onerror='nofound('${product.spid}')'/>"
							+"<img class='lazy' src='http://www.hnhcyy.com/resource/img/"+v.spid+"/10.jpg'/>"
							+"</div>"
							+"<div class='pop_price'>"
							+"<div class='clearfix'>"
							+v.spmch
							+" </div>"
							+"</div>"
							+"</div>"
							+"</a>"
						$(".list_container").append(list);
					})
				//}
			}
		})
	}
})